package sysint.json.sysint;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.spring.Main;
import org.apache.camel.model.dataformat.JsonLibrary;

public class FlightMain extends RouteBuilder {

	private static String JSON_URI = "http://flightradar24.com/PlaneFeed.json";

	private String intAirportRe = null;

	public static void <(String[] args) throws Exception {
		new Main().run(args);

	}

	public void configure() {

		from(JSON_URI).bean(new JsonToXml());
	}

	// TODO Xpath split

	//IF DE,CH,A
	//getsWeather();
	
	//IF Errorcode
	//sendMail();
	
	/*
	 * Sending mail if ErrorCodes Apllied
	 */
	private void sendMail() {
		SendMail send = new SendMail(this.intAirportRe);
		try {
			send.sendMail();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	// IF Airport in DE,CH,A
	private void getsWeather() {
		Weather myWeather = new Weather(this.intAirportRe);
		myWeather.getWeather();
	}

}
